import { getArticleDetailAPI } from "@/api/articleApi";

export default {
  namespaced: true,
  state: {
    images: [],
    article: {},
  },
  mutations: {
    addImage(state, payload) {
      state.images.push(payload);
    },
    clearImage(state) {
      state.images = [];
    },
    updateArticle(state, payload) {
      state.article = payload;
    },
  },
  actions: {
    async initArticle({ commit }, id) {
      const { data: res } = await getArticleDetailAPI(id);
      commit("updateArticle", res);
    },
  },
};
